<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="/MES_ADMIN_Project/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<title>Insert title here</title>
<script type="text/javascript">
	$(document).ready(function(){
		$("#component").click(function(){
			$.ajax({
				url : "componentKind.do",
				type: "post",
				dataType : "json",
				success:function(data){
					$("#thead").empty();
					$("#tbody").empty();
					$("#div").empty();
						$("#div").append($("<input type=button value=불량 id=is_fault_N>")).append($("<input type=button value=정상 id=is_fault_Y>")).append($("<input type=button value=전체 id=is_fault_all>"));
						$("#thead").append($("<tr>").append($("<th>").text("부품아이디"))
								.append($("<th>").text("부품이름"))
								.append($("<th>").text("불량")));
					for(i=0; i<data.list.length; i++){
						$("#tbody").append($("<tr>").append($("<td>").html(data.list[i].component_id))
								.append($("<td>").html(data.list[i].component_name))
								.append($("<td>").html(data.list[i].is_fault)));													
					}
				}
			});
		});
		$("#is_fault_N").live('click',function(){
			//정상인 제품
			$.ajax({
				url : "is_fault_N.do?is_fault="+"N",
				type : "post",
				dataType : "json",
				success:function(data){
					alert(data.message);
				}
			});
		});
		$("#is_fault_Y").live('click',function(){
			//불량이 제품
			$.ajax({
				url : "is_fault_N.do?is_fault="+"Y",
				type : "post",
				dataType : "json",
				success:function(data){
					alert(data.message);
				}
			});
 		});
		$("#is_fault_all").live('click',function(){
			//총 제품 
			$.ajax({
				url : "is_fault_N.do?is_fault="+"All",
				type : "post",
				dataType : "json",
				success:function(data){
					alert(data.message);
				}
			});
		});
		$("#machine_a1").click(function(){
			$.ajax({
				url : "machine_a.do",
				type: "post",
				dataType : "json",
				success:function(data){
					$("#thead").empty();
					$("#tbody").empty();
					$("#div").empty();
						$("#div").append($("<input type=button value=불량 id=is_fault_N>")).append($("<input type=button value=전송 id=is_fault_Y>")).append($("<input type=button value=전송 id=is_fault_all>"));
						$("#thead").append($("<tr>").append($("<th>").text("부품이름"))
								.append($("<th>").text("시작시간"))
								.append($("<th>").text("끝시간")));
					for(i=0; i<data.list.length; i++){
						$("#tbody").append($("<tr>").append($("<td>").html(data.list[i].component_id))
								.append($("<td>").html(data.list[i].working_start))
								.append($("<td>").html(data.list[i].working_end)));													
					}
				}
			});
		});
	});
</script>
</head>
<body>
<form action="">
	<table border="1">
		<tr>
			<td>부품</td>
			<td><input type="button" value="검색" id="component"></td>
		</tr>
		<tr>
			<td>A공정</td>
			<td><input type="button" value="검색" id="machine_a1"></td>
		</tr>
	</table>
</form>
<Br>
<div id="div"></div>
<table border="1">
	<thead id="thead"></thead>
	<tbody id="tbody"></tbody>
</table>
</body>
</html>






